﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Linq;
using System.Text;

namespace KandieWebProjectI.DAL.Helper
{
    public class ConnectionHelper
    {
        private string stringConexao = System.Configuration.ConfigurationManager
                        .ConnectionStrings["SqlServerConnectionString"].ConnectionString;

        public void OpenConnection(DbConnection connection)
        {
            if(connection.State != ConnectionState.Open)
            {
                connection.ConnectionString = stringConexao;
                connection.Open();
            }
        }

        public void CloseConnection(DbConnection connection)
        {
            if (connection.State == ConnectionState.Open)
            {
                connection.Close();
            }
        }
    }
}
